package com.atguigu.eduservice.controller;


import com.atguigu.commonutils.R;
import com.atguigu.eduservice.entity.subject.OneSubject;
import com.atguigu.eduservice.service.EduSubjectService;
import org.apache.ibatis.annotations.One;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2020-04-12
 */
@RestController
@RequestMapping("/eduservice/edu-subject")
public class EduSubjectController {

    //Swagger 测试地址: http://localhost:8001/swagger-ui.html
    @Autowired
    private EduSubjectService subjectService;

    //添加课程分类
    //获取上传的文件 读取内容
    @PostMapping("addSubject")
    public R addSubject(MultipartFile file){
        //得到excel文件
        subjectService.saveSubject(file,subjectService);
        return R.ok();
    }

    //课程分类列表----树形结构
    @GetMapping("getAllSubject")
    public R getAllSubject(){
        List<OneSubject> list = subjectService.getALLSubject();
        return R.ok().data("list",list);
    }

}

